package nio.bytebuffer;

import java.nio.ByteBuffer;

public class Wrap {

    public static void main(String[] args) {

        byte[] byteArray = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
        ByteBuffer bytebuffer1 = ByteBuffer. wrap( byteArray);
        System.out.println(" bytebuffer1 capacity=" + bytebuffer1.capacity()
                + " limit=" + bytebuffer1.limit()
                + " position=" + bytebuffer1.position()); // bytebuffer1 capacity=8 limit=8 position=0

        System.out.println();

        ByteBuffer bytebuffer2 = ByteBuffer. wrap( byteArray, 2, 4);
        System.out.println(" bytebuffer2 capacity=" + bytebuffer2. capacity()
                + " limit=" + bytebuffer2.limit()
                + " position=" + bytebuffer2.position()); // bytebuffer2 capacity=8 limit=6 position=2

    }

}
